﻿package mortal.game.view.mining
{
    import extend.language.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.map3D.AstarAnyDirection.data.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class MiningIcon extends ActionBaseIcon
    {
        private static var _instance:MiningIcon;

        public function MiningIcon()
        {
            super(ResFileConst.MiningTaskDoubleRewardIcon);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            return;
        }// end function

        override public function setLeftTimeAndState(param1:int, param2:int = 1, param3:String = "mm:ss", param4:Boolean = true) : void
        {
            super.setLeftTimeAndState(param1, param2);
            if (_state == ActionBaseIcon.State_Opening)
            {
                playEffect();
            }
            else
            {
                stopEffect();
            }
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            if (_state == ActionBaseIcon.State_ToBeOpen)
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(21043, currentTimeStr), MsgRollTipsType.msgRollTips3);
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.MiningShowModule, true));
            var _loc_2:* = ThingUtil.npcUtil.getNpc(1100009);
            if (_loc_2 != null)
            {
                if (GeomUtil.calcDistance(RolePlayer.instance.x2d, RolePlayer.instance.y2d, _loc_2.x2d, _loc_2.y2d) > GameConst.NpcInDistance + 40)
                {
                    (GameController.mining.view as MiningModule).isDouble = true;
                }
                else
                {
                    (GameController.mining.view as MiningModule).isDouble = false;
                }
            }
            else
            {
                (GameController.mining.view as MiningModule).isDouble = true;
            }
            return;
        }// end function

        public static function get instance() : MiningIcon
        {
            if (_instance == null)
            {
                _instance = new MiningIcon;
            }
            return _instance;
        }// end function

        public static function get hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
